package com.ys.cloud.nacos.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>@description: </p>
 *
 * @author yangshuang
 * @version 1.0
 * @date 2019/6/9 13:34
 */
@RestController
public class EchoController {

    @Autowired
    private RestTemplate restTemplate;


    @GetMapping(value = "/consumer/echo/{message}")
    public String echo(@PathVariable String message) {

        Map<String, Object> uriVariable = new HashMap<>();
        uriVariable.put("message", message);

        return restTemplate.getForObject("http://spring-cloud-nacos-rest-provider/echo/{message}", String.class, uriVariable);
    }
}
